<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DecimalFormat"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="me.yobol.greentable.commons.path.*" %>
<%@ page import="me.yobol.greentable.bean.OrderBean" %>
<%@ page import="me.yobol.greentable.bean.OrderCommodityBean" %>
<%@ page import="me.yobol.greentable.bean.IngredientBean" %>
<%@page import="me.yobol.greentable.service.IngredientService"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>Please confirm your order</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
  <%
  	Map<String,Object> orderData = (Map)request.getSession().getAttribute("orderData");
  	String flag = (String)orderData.get("flag");
  	if(flag == null){
  		out.print("Please confirm your order:<br/>");
  	}
  %>
	<form action="<%=SPath.sCommitOrder(request) %>" method="post">
  <%
	int numOfOrder = 0;
	float totalPrice = 0;
  	if(orderData != null){
  		numOfOrder = (Integer)orderData.get("num");
  		for(int i = numOfOrder - 1;i >= 0;i--){
  			OrderBean o = (OrderBean)orderData.get("o" + i);
  			List<OrderCommodityBean> ocs = (List)orderData.get("ocs" + i);
  				if(o != null && ocs != null){
  %>
  					<div>
  						<p>CustomerId : <%=o.getCustomerId() %>&nbsp;&nbsp;&nbsp;&nbsp;TraderId : <%=o.getTraderId() %></p>
  						<p>下单时间:<%=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(o.getOrderTime()) %></p>
  						<input type="hidden" name="oId" value="<%=o.getOrderId() %>"/>
  <%
  					for(int j = 0;j < ocs.size();j++){
  						OrderCommodityBean oc = ocs.get(j);
  						IngredientBean ig = IngredientService.getIngredientByIngredientId(oc.getIngredientId());
  						totalPrice += ig.getIngredientPrice() * oc.getCommodityQuantity();
  %>
  						<a href="<%=SPath.sGetIngredient(request, "?ingredientId=" + oc.getIngredientId()) %>">
  							<img src="<%=ig.getIngredientImg() %>" width="64px" height="64px"/><%=ig.getIngredientName() %>&nbsp;&nbsp;&nbsp;&nbsp; <%=ig.getIngredientPrice() %> * <%=oc.getCommodityQuantity() %>
  						</a>
  <%
  					}
  %>
  					</div>
  <%
  			}
  		}
  	}
  %>
  
  <%
  	if(flag == null){
  %>
  	<p>总价：<span style="font-size:18px;color:red;font-style:bolder"><%=new DecimalFormat(".00").format(totalPrice) %></span></p>
  	<input type="submit" value="提交订单"/>
  <%
  	}else if(flag.equals("query_processing")){
  %>
  <%
  	}
  %>
  	</form>
  </body>
</html>